<?php

namespace App\Models;

use Encore\Admin\Traits\AdminBuilder;
use Encore\Admin\Traits\ModelTree;
use Illuminate\Database\Eloquent\Model;

class Category extends Model {

    use ModelTree,
        AdminBuilder;

    protected $table = 'categories';

//    public function __construct(array $attributes = []) {
//        parent::__construct($attributes);
//
//        $this->setParentColumn('parent_id');
//        $this->setOrderColumn('order');
//        $this->setTitleColumn('title');
//    }

    public function goods() {
        return $this->hasMany(Goods::class, 'category_id');
    }

    public function getLogoAttribute($attribute) {
        return $attribute ? config('admin.upload.host') . '/' . $attribute : '';
    }

}
